﻿using Management.Core.News;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Management.Areas.Control.Controllers
{
    [AdminAuthorize]
    public class HomeController : Controller
    {        
        [OutputCache(CacheProfile = "YLConfigCache")]
        //[AllowAnonymous]
        // 主页面
        public ActionResult Index()
        {            
            return View();
        }
        [AllowAnonymous]
        public ActionResult GetNews()
        {
            NewsManager nm = new NewsManager();
            DateTime start = DateTime.Now.AddDays(-1);
            DateTime end = DateTime.Now;
            List<string> list = new List<string>();
            var news = nm.FindList(u => u.Updated_at > start && u.Updated_at < end).OrderByDescending(u=>u.Updated_at).FirstOrDefault();
            if (news != null)
            {
                list.Add(news.Author + "于" + news.Updated_at + " 发布了<a href='News/Detail/" + news.NewsID + "'>《" + news.Title + "》</a>的文章");
            }
            return Json(new { msg = list, count = list.Count()}, JsonRequestBehavior.AllowGet);
        }
    }
}